package com.cdut.logistics.model.dao.datacentre;

import java.util.Date;

import com.cdut.logistics.model.entity.datacentre.BaseAcademic;
import com.jfinal.plugin.activerecord.Db;

/**  
 * @ClassName: academic 
 * @Description: 操作数据库 
 * @author wxt.xia
 * @date 2018年1月26日 上午9:13:52    
 */
public class Academic extends BaseAcademic<Academic>{
	private static final long serialVersionUID = 1L;
	public String baseSql = " and is_use = 1";
	public String sql1 = "SELECT "+
			"academy.id,"+
			"academy.`name`,"+
			"school.name as 'school_name' "+
			"FROM academy  join school "+
			"ON academy.school_id=school.id "+
			"AND academy.is_use = 1 "+
			"AND school.is_use = 1 "+
			"AND academy.name like ?";
	public String sql2 = "SELECT "+
			"academy.id,"+
			"academy.`name`,"+
			"school.name as 'school_name' "+
			"FROM academy  join school "+
			"ON academy.school_id=school.id "+
			"AND academy.is_use = 1 "+
			"AND school.is_use = 1 "+
			"AND academy.id =?";
	public String sql4 = "select * from academy where school_id like ?"+ baseSql;
	public String sql3 = "UPDATE academy set is_use =?, updated=? where id =?"+ baseSql;
	/**  
	 * @Title: save  
	 * @Description: 新增学院
	 * @author wxt.xia
	 * @param academic
	 * @throws  
	 */
	public void save(Academic academic) {
		academic.set("created", new Date());
		academic.set("updated", new Date());
		academic.set("is_use", 1);
		academic.set("active", 1);
		academic.save();
	}
	
	/**  
	 * @Title: remove  
	 * @Description: 删除学院
	 * @author wxt.xia
	 * @param id
	 * @throws  
	 */
	public void remove(int id) {
		Db.update(sql3,0,new Date(),id);
	}

	/**  
	 * @Title: queryById  
	 * @Description: 根据学院id查询
	 * @author wxt.xia
	 * @param id
	 * @return
	 * @throws  
	 */
	public Academic queryById(int id) {
		return findById(id);
	}
}
